import {Sign} from "../energy/api";
import {AdminService} from "../AdminService";
import {UserService} from "../UserService";

export class BaseRequest implements Sign{
  sign: string = "";
  sysId: string = "";
  sysName: string = "";
  timestamp: string = new Date().getTime().toString();
  data:any;
  constructor(other:any){
    this.data = other;
    for(let key in this.data){
      if(this.data[key]==null){
        delete this.data[key];
      }
    }
    if(AdminService.admin!=null){
      this.sign = AdminService.admin.sysId.toString();
      this.sysId = AdminService.admin.sysId.toString();
      this.sysName = AdminService.admin.sysId.toString();
    }else if(UserService.user!=null){
      this.sign = UserService.user.sysId.toString();
      this.sysId = UserService.user.sysId.toString();
      this.sysName = UserService.user.sysId.toString();
    }
  }
}
